#include "../log.h"
#include "../os.h"
#include "../png.h"
+#ifdef HAVE_FASTLZ
+#include "../fastlz.h"
+#endif
#include "record.h"
//#define STATS
//45.2% images (3055340 bytes) (without filter)
//39.9% images (2458904 bytes) (with filter, Z_BEST_SPEED)
//35.3% images (2027305 bytes) (with filter, Z_BEST_COMPRESSION)
+ //48.0% images (3480495 bytes) (with filter, fastlz)
+
unsigned char*filter = malloc(img->height);
int y;
gfxcolor_t*image = malloc(img->width*img->height*sizeof(gfxcolor_t));
int size = img->width*img->height;
uLongf compressdata_size = compressBound(size*sizeof(gfxcolor_t));
void*compressdata = malloc(compressdata_size);
+
+#ifdef HAVE_FASTLZ
+ compressdata_size = fastlz_compress_level(1, (void*)image, size*sizeof(gfxcolor_t), compressdata);
+#else
compress2(compressdata, &compressdata_size, (void*)image, sizeof(gfxcolor_t)*size, Z_BEST_SPEED);
+#endif
+
writer_writeU32(w, compressdata_size);
w->write(w, filter, img->height);
w->write(w, compressdata, compressdata_size);
unsigned char*filter = malloc(img.height);
r->read(r, filter, img.height);
r->read(r, compressdata, compressdata_size);
+
+#ifdef HAVE_FASTLZ
+ fastlz_decompress(compressdata, compressdata_size, (void*)img.data, size);
+#else
uncompress((void*)img.data, &size, compressdata, compressdata_size);
+#endif
+
int y;
unsigned char*line = malloc(img.width*sizeof(gfxcolor_t));
for(y=0;y<img.height;y++) {